<!DOCTYPE HTML>
<html>
<head>
    <title>Error</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body>
<form id="form1" name="form1">
    <span style="width:80px;display:inline-block;">分类名：</span>
    <input id="name" name="typeName" class="mini-textbox" required="true" style="width:155px;"  />

    <span style="width:80px;display:inline-block;">图片：</span>
    <input class="mini-htmlfile" type="file" name="Fdata"  required="true" id="file1" style="width:155px;" />
    <br/><br/>

    <span style="width:80px;display:inline-block;">类型：</span>
    <input id="type" name="type" class="mini-combobox" data="classType"  onvaluechanged="choiceType"   style="width:155px;"  value="<%=type%>" />
    <span id="imgDetail" style="color: #ff0000"></span>
    <br/><br/>
    <img src="/classImg/classType.png" style="display:block;height: 400px"/>
</form>

<div style="padding-top: 10px;text-align: center">
    <a class="mini-button " iconCls="icon-ok" onclick="addUserLevel()">确定</a>
    <a class="mini-button" iconCls="icon-cancel" onclick="onCancel">取消</a>
</div>
</body>
<script>
    classType=[{id:1,text:"海报分类管理"},{id:2,text:"标题分类管理"},{id:3,text:"商品分类管理"}]
    mini.parse();
    function addUserLevel() {
        var data = new FormData($('#form1')[0]);
        var form = new mini.Form("#form1");
        form.validate();
        if (form.isValid() == false) {
            alert("请正确填写数据")
            return
        };
        $.ajax({
            type: "POST",
            url: "/getdata/classification/add",
            data:data,
            contentType: false,    //不可缺
            processData: false,    //不可缺
            success: function (result) {
                if(result==1){
                    CloseWindow("save");
                }else{
                    alert("更改失败");
                    CloseWindow("save");
                }
            }
        })
    }
    //    关闭窗口
    function CloseWindow(action) {
        if (action == "close" && form.isChanged()) {
            if (confirm("数据被修改了，是否先保存？")) {
                return false;
            }
        }
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }
    function onOk(e) {
        SaveData();
    }
    function onCancel(e) {
        CloseWindow("cancel");
    }
    function choiceType(e) {
        var newType = mini.get("type").getValue();
        changeType(newType);
    }
    $(document).ready(function(){
        var typeValue = mini.get("type").getValue();
        changeType(typeValue);
    });
    function changeType(type) {
        if(type==1){
            $("#imgDetail").text("请上传宽比为3:1(750*250)格式的图片(图片过大会自动裁剪)")
        }else if(type==2){
            $("#imgDetail").text("请上传宽比为1:1(180*180)格式的图片(图片过大会自动裁剪)")
        }else if(type==3){
            $("#imgDetail").text("请上传宽比为2:1(750*375)格式的图片(图片过大会自动裁剪)")
        }
    }
</script>
</html>